<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body >

<div id="app">
	<h1>Hello App!</h1>
	<p>
		<router-link to="/user/21">Go to Foo</router-link><br/>
		<router-link :to="{name:'user', params:{userId:123}}">Go to Foo2</router-link>
	</p>
	<router-view></router-view>
</div>
	
		
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.9/vue.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/vue-router/3.4.8/vue-router.js"></script>
<script>
	const User = {
		template:'<div><h2>User {{$route.params.userId}}</h2><router-view></router-view></div>',
		watch:{
			$route(to, from){
				console.log(to);
				console.log(from);
			}
		},
	};
	const router = new VueRouter({
		routes: [{
			path: '/user/:userId',
			name: 'user',
			component: User,
		}],
	});
	const app = new Vue({
		router
	}).$mount('#app');
</script>
</html>



















































